<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>确认订单</title>
    <script src="${pageContext.request.contextPath}/script/jquery-1.11.3.js"></script>
	<script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript">
	    /* 导航条 */
	    $(window).scroll(function () {
	        if ($(".navbar").offset().top > 50) {$(".navbar-fixed-top").addClass("top-nav");
	        }else {$(".navbar-fixed-top").removeClass("top-nav");}
	    });
        $(function(){
//            计算总价
            ycy_mso_caltotalprice();
            //计算预计派送日期
            ycy_mso_caltime();
//            其他地址 按钮
            var mso_isopen=false;
           $(".ycy-mso-address-info>p").click(function(){
               if(mso_isopen){
                   $(".ycy-mso-address-select").hide(500);
                   mso_isopen=false;
               }else{
                   $(".ycy-mso-address-select").show(500);
                   mso_isopen=true;
               }
           });

//            选择地址
            $(".ycy-mso-address-select>li").click(function(){
               $(".ycy-mso-address-info-details").text($(this).text());
               $(".ycy-mso-address-info-details").attr("data-ref",$(this).attr("data-ref"));
               $(".ycy-mso-address-hide").removeClass("ycy-mso-address-hide");
                $(this).addClass("ycy-mso-address-hide");
              	//地址Id
                updateAddressId();
            });
            
          //地址Id
            updateAddressId();
        });
        
        //计算总价
        function ycy_mso_caltotalprice(){
            var totalprcie=0;
            $(".ycy-mso-pricestyle-price").each(function(){
                var price = $(this).text();
                totalprcie+=price*1;
            });
            $(".ycy-mso-totalprice").text(totalprcie.toFixed(2));
        }
        //计算预计派送日期
        function ycy_mso_caltime(){
           var date = new Date();
            date.setMinutes(date.getMinutes()*1+30);
           var nowdate=date.getFullYear()+"-"+(date.getMonth()*1+1)+"-"+date.getDate()+" "+date.getHours()
                        +":"+date.getMinutes();
           $(".ycy-mso-address-willtime").text(nowdate);
        }
        //地址Id
        function updateAddressId(){
        	$("#addrId").val($(".ycy-mso-address-info-details").attr("data-ref"));
        }
    </script>
    
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">

	<link href="${pageContext.request.contextPath}/css/foot.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/css/head2.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/css/menuNav.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/makeSureOrder.css"/>
</head>
<body>
	
	<div class="container">
	    <!-- 回到顶部 开始-->
		<c:import url="/shared/returnTop.jsp" />
	    <!--回到顶部 结束-->
	    
	    <!--导航-->
		<c:import url="/shared/header.jsp" />
	    <!--导航结束-->
	    
	    
	    <!--中间部分-->
	    <div class="row">
	        <!--内容  小伙伴请补充-->
	        <div class="col-md-10">
	        	<c:set var="userInfo" value="${sessionScope.user}"/>
	            <c:choose>
	            	<c:when test="${empty userInfo}">
	            		<div style="color:white;text-align:center;font-size:20px;">您还没登录，无法查看订单</div>
	            	</c:when>
	            	<c:otherwise>
	            		<form action="ShoppingCartSubmitOrder.html" method="post">
	            			<div class="table-responsive ycy-mso-div">
				                <div class="ycy-mso-address">
				                    <div class="ycy-mso-address-base">
				                        <span>收货人：</span>
				                        <span>${userInfo.userName }</span>
				                        <span class="ycy-mso-address-base-phone">${userInfo.phone }</span>
				                    </div>
				                    <div class="ycy-mso-address-time">
				                        <span>预计到达时间：</span>
				                        <span class="ycy-mso-address-willtime"></span>
				                    </div>
				                    <div class="ycy-mso-address-info">
				                        <span>收货地址：</span>
				                        <input type="hidden" name="addrId" id="addrId"/>
				                        <span class="ycy-mso-address-info-details" data-ref="${userInfo.addressList[0].addrid}">${userInfo.addressList[0].completeAddress}</span>
				                        <p>其&nbsp;他&nbsp;地&nbsp;址</p>
				                    </div>
				                    <input type="hidden" name="addrId" id="addrId"/>
				                    <ul class="ycy-mso-address-select">
				                        <li class="ycy-mso-address-hide" data-ref="${userInfo.addressList[0].addrid}">${userInfo.addressList[0].completeAddress}</li>
				                        <c:forEach var="addr" items="${userInfo.addressList }" begin="2">
				                        	<li data-ref="${addr.addrid}">${addr.completeAddress}</li>
				                        </c:forEach>
				                    </ul>
				                </div>
				                <!--商品名称 单价 数量-->
				                <table class="table" style="color:white" id="ycy-mos-table">
				                    <tr>
				                        <td colspan="4" class="ycy-mos-ordertitle" style="border-top-style: hidden;">订单信息</td>
				                    </tr>
				                    <c:forEach var="order" items="${sessionScope.selectedOrderList}">
				                    	<tr>
					                        <td><img src="${pageContext.request.contextPath}/image/foods/${order.rate.food.imageFile}" height="100" width="100"></td>
					                        <td class="ycy-mso-namestyle">
					                            <span class="ycy-mso-foodname">${order.rate.food.foodName}</span>
					                            <p class="ycy-mso-foodsize">${order.rate.foodSize.foodSizeName}</p>
					                        </td>
					                        <td class="ycy-mso-pricestyle">&yen;<span class="ycy-mso-pricestyle-price">${order.unitPrice}</span></td>
					                        <td  class="ycy-mso-countcellstyle">x<span class="ycy-mso-count">${order.count}</span></td>
					                    </tr>
				                    </c:forEach>
				                    <tr>
				                        <td colspan="2" class="ysy-mso-pricecell">
				                            <span class="ycy-mso-totalpricetext">合计：&yen;</span>
				                            <span class="ycy-mso-totalprice">0</span>
				                        </td>
				                        <td colspan="2" class="ysy-mso-btncell">
				                            <button type="submit" class="btn-danger" id="ycy-mso-settlebtn">结&nbsp;&nbsp;算</button>
				                        </td>
				                    </tr>
				                </table>
				            </div>
	            		</form>
	            	</c:otherwise>
	            </c:choose>
	        </div>
	        <!--内容结束-->
	    </div>
	    <!--中间部分结束-->
	    
		<!--尾部-->
		<c:import url="/shared/footer.jsp" />
		<!--尾部结束-->
	</div>
</body>
</html>